package com.fbs.wowo.userFollow.web;


import com.fbs.wowo.base.BaseController;
import com.fbs.wowo.base.Response;
import com.fbs.wowo.userFollow.entity.FollowOrFansListResponse;
import com.fbs.wowo.userFollow.entity.UserFollow;
import com.fbs.wowo.userFollow.service.UserFollowService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("userFollow")
@Controller
public class UserFollowController extends BaseController {

    @Resource
    private UserFollowService userFollowService;

    /**
     * 关注
     * @param userFollow
     * @return
     */
    @PostMapping("insertFollow")
    @ResponseBody
    public Response insertFollow(UserFollow userFollow){
        userFollowService.insertSelective(userFollow);
        return success();
    }

    /**
     * 取消关注
     * @param
     * @return
     */
    @PostMapping("deleteFollow")
    @ResponseBody
    public Response deleteFollow(String userId,String followedUser){
        userFollowService.deleteByPrimaryKey(userId,followedUser);
        return success();
    }


    /**
     * 查询关注详情
     * @param userId
     * @param followedUser
     * @return
     */
    @GetMapping("findUserFollow")
    @ResponseBody
    public Response findUserFollow(String userId, String followedUser){
        UserFollow userFollow = userFollowService.selectByPrimaryKey(userId, followedUser);
        return success(userFollow);
    }


    /**
     * 用户关注列表
     */
    @GetMapping("findFollowList")
    @ResponseBody
    public Response findFollowList(String userId){
        List<FollowOrFansListResponse> followList = userFollowService.findFollowList(userId);
        return success(followList);
    }


    /**
     * 用户粉丝列表
     */
    @GetMapping("findFansList")
    @ResponseBody
    public Response findFansList(String userId){
        List<FollowOrFansListResponse> fansList = userFollowService.findFansList(userId);
        return success(fansList);
    }


}
